@meowdown/core 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +247 -193
- package/dist/index.js +14 -14
- package/dist/style.css +11 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -53,11 +53,11 @@ Heading shortcuts toggle the current block to a heading of that level (or back t
|
|
|
53
53
|
|
|
54
54
|
Selection colors are standalone variables, not derived from `--meowdown-accent`, so selection can be restyled independently.
|
|
55
55
|
|
|
56
|
-
Tags (`#tag`) render as pills via the `.md-tag` class, tinted from `--meowdown-accent`.
|
|
56
|
+
Tags (`#tag`) render as pills via the `.md-tag` class, tinted from `--meowdown-accent`. Wire click handling with `defineTagClickHandler(({ tag, event }) => ...)` (or `@meowdown/react`'s `onTagClick` prop); `tag` is read from the rendered text without the leading `#`.
|
|
57
57
|
|
|
58
58
|
Wikilinks (`[[target]]`/`[[target|alias]]`) render in place via a mark view as an immutable label (the alias, or the target when there is no alias), with the raw source hidden in hide and focus modes and shown dimmed in show mode. The label uses the `.md-wikilink-label` class and the raw source the `.md-wikilink-source` class, both dashed-underlined and colored by `--meowdown-accent`. In every mark mode the link is a single immutable caret stop: arrowing onto it selects the whole source (ringed with `--meowdown-node-outline` in hide and focus, the native selection over the visible source in show), and Backspace/Delete remove it as a unit. Wire click navigation with `defineWikilinkClickHandler(({ target, event }) => ...)` (or `@meowdown/react`'s `onWikilinkClick` prop).
|
|
59
59
|
|
|
60
|
-
Markdown links (`[text](url)`) render the label as an `<a href>` with the `.md-link` class, colored by `--meowdown-accent`; the `[`, `]`, and `(url)` syntax dims in show mode and hides in hide and focus modes. Wire click handling with `defineLinkClickHandler(({ href, event }) => ...)` (or `@meowdown/react`'s `onLinkClick` prop).
|
|
60
|
+
Markdown links (`[text](url)`) render the label as an `<a href>` with the `.md-link` class, colored by `--meowdown-accent`; the `[`, `]`, and `(url)` syntax dims in show mode and hides in hide and focus modes. Wire click handling with `defineLinkClickHandler(({ href, event }) => ...)` (or `@meowdown/react`'s `onLinkClick` prop).
|
|
61
61
|
|
|
62
62
|
Bare URLs autolink without `[text](url)` brackets and share the same `.md-link` rendering and click handling: a scheme URL (`https://example.com`), an angle autolink (`<https://example.com>`), a `www.` host (`www.example.com`), an email (`me@example.com`), and a bare domain (`google.com`, `sub.domain.io/path`). Bare domains are matched against a curated list of common TLDs, so file names and prose keep their dots without linkifying (`README.md`, `node.js`, `i.e.` stay plain text); reach for `[text](url)` or `<url>` to link anything off that list. Autolinks are derived live from the text, so editing one re-evaluates it; the caret sitting inside a link never un-links it.
|
|
63
63
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExtension, Priority, Union, withPriority } from "@prosekit/core";
|
|
2
|
+
import { PlaceholderOptions, definePlaceholder } from "@prosekit/extensions/placeholder";
|
|
3
|
+
import { defineReadonly } from "@prosekit/extensions/readonly";
|
|
2
4
|
import { CodeBlockAttrs } from "@prosekit/extensions/code-block";
|
|
3
5
|
import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
|
|
4
6
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
//#region src/converters/check-roundtrip.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* How faithfully markdown survives a parse-then-serialize round trip:
|
|
10
|
+
* - `exact`: byte-identical (modulo the trailing newline).
|
|
11
|
+
* - `normalizing`: same non-blank lines ignoring trailing whitespace; only
|
|
12
|
+
* blank-line layout (including empty `>` lines inside a blockquote) or
|
|
13
|
+
* insignificant trailing whitespace differs.
|
|
14
|
+
* - `lossy`: a non-blank line changed, so content would be lost or altered.
|
|
15
|
+
*/
|
|
16
|
+
type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
|
|
17
|
+
/** Options for {@link checkRoundTrip}. */
|
|
18
|
+
interface CheckRoundTripOptions {
|
|
19
|
+
/** Whether to handle a leading `---` frontmatter block. Off by default. */
|
|
20
|
+
frontmatter?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Classify how `markdown` survives the editor's parse-then-serialize round trip. */
|
|
23
|
+
declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
24
|
+
//#endregion
|
|
8
25
|
//#region src/extensions/frontmatter.d.ts
|
|
9
26
|
/**
|
|
10
27
|
* The raw YAML frontmatter body, stored verbatim (the text between the opening
|
|
@@ -50,6 +67,41 @@ type HorizontalRuleMarkerExtension = Extension<{
|
|
|
50
67
|
}>;
|
|
51
68
|
type MeowdownHorizontalRuleExtension = Union<[HorizontalRuleExtension, HorizontalRuleMarkerExtension]>;
|
|
52
69
|
//#endregion
|
|
70
|
+
//#region src/extensions/html-comment.d.ts
|
|
71
|
+
interface MeowdownHTMLCommentAttrs {
|
|
72
|
+
/**
|
|
73
|
+
* The literal markdown comment, including its delimiters, e.g.
|
|
74
|
+
* `<!-- reflect-capture-page-text:start -->`. A multi-line comment keeps its
|
|
75
|
+
* embedded newlines verbatim so the round-trip is lossless.
|
|
76
|
+
*/
|
|
77
|
+
content: string;
|
|
78
|
+
}
|
|
79
|
+
type HTMLCommentExtension = Extension<{
|
|
80
|
+
Nodes: {
|
|
81
|
+
htmlComment: MeowdownHTMLCommentAttrs;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* A block-level HTML comment (`<!-- ... -->`) as an invisible, atomic node.
|
|
86
|
+
*
|
|
87
|
+
* Markdown is the source of truth, so a comment must survive a round-trip — but
|
|
88
|
+
* a comment is, by definition, not rendered output. Rather than spilling the raw
|
|
89
|
+
* `<!-- ... -->` into a paragraph (where it reads as body text), the parser maps
|
|
90
|
+
* a `CommentBlock` onto this node: the text rides on the `content` attribute and
|
|
91
|
+
* `toDOM` hides it with `display: none`, so it stays in the document and
|
|
92
|
+
* serializes back verbatim while never showing in the editor. Useful for
|
|
93
|
+
* sentinel markers that tools embed around a region of a note.
|
|
94
|
+
*
|
|
95
|
+
* Only block-level comments (a `<!-- ... -->` that owns its line) become this
|
|
96
|
+
* node. An inline comment in the middle of a paragraph is left as literal text,
|
|
97
|
+
* and raw HTML blocks (`<div>…`) stay visible paragraphs — they can carry
|
|
98
|
+
* content a reader expects to see.
|
|
99
|
+
*
|
|
100
|
+
* The node is `atom` (no editable content) and not selectable: it is an opaque,
|
|
101
|
+
* invisible marker the cursor steps over rather than a block the user edits.
|
|
102
|
+
*/
|
|
103
|
+
declare function defineHTMLComment(): HTMLCommentExtension;
|
|
104
|
+
//#endregion
|
|
53
105
|
//#region src/extensions/inline-marks.d.ts
|
|
54
106
|
interface MdImageViewAttrs {
|
|
55
107
|
src: string;
|
|
@@ -75,7 +127,7 @@ interface MdPackAttrs {
|
|
|
75
127
|
* same kind are kept apart by it (so they do not merge into one mark run), and
|
|
76
128
|
* it stays stable when unrelated text in the block is edited, so editing one
|
|
77
129
|
* unit never re-marks the others. Values: `bold` | `italic` | `code` |
|
|
78
|
-
* `strike` | `autolink` | `link_${href}` | `image_${src}`.
|
|
130
|
+
* `strike` | `highlight` | `autolink` | `link_${href}` | `image_${src}`.
|
|
79
131
|
*/
|
|
80
132
|
key: string;
|
|
81
133
|
}
|
|
@@ -128,7 +180,11 @@ declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<rea
|
|
|
128
180
|
setextUnderline?: number | null;
|
|
129
181
|
};
|
|
130
182
|
};
|
|
131
|
-
}>, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/heading").HeadingCommandsExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/table").TableSpecExtension, import("@prosekit/extensions/table").TableRowSpecExtension, import("@prosekit/extensions/table").TableCellSpecExtension, import("@prosekit/extensions/table").TableHeaderCellSpecExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension, MeowdownHorizontalRuleExtension, import("@prosekit/core").
|
|
183
|
+
}>, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/heading").HeadingCommandsExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/table").TableSpecExtension, import("@prosekit/extensions/table").TableRowSpecExtension, import("@prosekit/extensions/table").TableCellSpecExtension, import("@prosekit/extensions/table").TableHeaderCellSpecExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension, MeowdownHorizontalRuleExtension, import("@prosekit/core").Extension<{
|
|
184
|
+
Nodes: {
|
|
185
|
+
htmlComment: MeowdownHTMLCommentAttrs;
|
|
186
|
+
};
|
|
187
|
+
}>, import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
132
188
|
Marks: {
|
|
133
189
|
mdMark: import("@prosekit/pm/model").Attrs;
|
|
134
190
|
};
|
|
@@ -156,6 +212,10 @@ declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<rea
|
|
|
156
212
|
Marks: {
|
|
157
213
|
mdDel: import("@prosekit/pm/model").Attrs;
|
|
158
214
|
};
|
|
215
|
+
}>, import("@prosekit/core").Extension<{
|
|
216
|
+
Marks: {
|
|
217
|
+
mdHighlight: import("@prosekit/pm/model").Attrs;
|
|
218
|
+
};
|
|
159
219
|
}>, import("@prosekit/core").Extension<{
|
|
160
220
|
Marks: {
|
|
161
221
|
mdTag: import("@prosekit/pm/model").Attrs;
|
|
@@ -186,59 +246,109 @@ declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<rea
|
|
|
186
246
|
toggleStrong: [];
|
|
187
247
|
toggleCode: [];
|
|
188
248
|
toggleDel: [];
|
|
249
|
+
toggleHighlight: [];
|
|
189
250
|
};
|
|
190
251
|
}>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>;
|
|
191
252
|
type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
|
|
192
253
|
declare function defineEditorExtension(): EditorExtension;
|
|
193
254
|
type TypedEditor = Editor<EditorExtension>;
|
|
194
255
|
//#endregion
|
|
195
|
-
//#region src/extensions/
|
|
256
|
+
//#region src/extensions/schema.d.ts
|
|
257
|
+
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
258
|
+
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
259
|
+
/** Typed mark builders bound to the shared schema. */
|
|
260
|
+
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/converters/md-to-pm.d.ts
|
|
263
|
+
/** Options for {@link markdownToDoc}. */
|
|
264
|
+
interface MarkdownToDocOptions {
|
|
265
|
+
/** Node builders to build the document with. Defaults to the shared schema's builders. */
|
|
266
|
+
nodes?: TypedNodeBuilders;
|
|
267
|
+
/** Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default. */
|
|
268
|
+
frontmatter?: boolean;
|
|
269
|
+
}
|
|
196
270
|
/**
|
|
197
|
-
*
|
|
198
|
-
* editor serializes content to the clipboard.
|
|
271
|
+
* Convert a markdown string into a ProseMirror document node.
|
|
199
272
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
273
|
+
* By default the document is built with the shared schema's node builders, so
|
|
274
|
+
* no editor is required. When the result will be loaded into a specific editor,
|
|
275
|
+
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
276
|
+
* instance and can be inserted without a JSON round trip.
|
|
277
|
+
*
|
|
278
|
+
* The output follows the extension set defined in `../extensions/extension.ts`
|
|
279
|
+
* (doc, paragraph, text, heading, blockquote, list, codeBlock, table, tableRow,
|
|
280
|
+
* tableCell, tableHeaderCell, horizontalRule). The function does not produce
|
|
281
|
+
* inline marks because the markdown stays literal text - emphasis / link /
|
|
282
|
+
* inline-code characters survive verbatim.
|
|
203
283
|
*/
|
|
204
|
-
|
|
205
|
-
declare function defineMarkMode(mode: MarkMode): PlainExtension;
|
|
284
|
+
declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
206
285
|
//#endregion
|
|
207
|
-
//#region src/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
286
|
+
//#region src/converters/pm-to-md.d.ts
|
|
287
|
+
/** Options for {@link docToMarkdown}. */
|
|
288
|
+
interface DocToMarkdownOptions {
|
|
289
|
+
/** Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default. */
|
|
290
|
+
frontmatter?: boolean;
|
|
211
291
|
}
|
|
212
|
-
|
|
213
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Convert a ProseMirror document into a Markdown string.
|
|
294
|
+
*
|
|
295
|
+
* Performance design:
|
|
296
|
+
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
297
|
+
* Avoids per-block intermediate strings while keeping the
|
|
298
|
+
* function-per-node-type readability of a switch dispatch.
|
|
299
|
+
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
300
|
+
* restored via local variables across nested calls - no fresh
|
|
301
|
+
* context objects per recursion.
|
|
302
|
+
* - Inline content is walked directly (not via `node.textContent`) to
|
|
303
|
+
* skip one intermediate string allocation per leaf block.
|
|
304
|
+
* - Backtick fence width and cell escaping use single linear loops, no
|
|
305
|
+
* regex on the hot path.
|
|
306
|
+
*/
|
|
307
|
+
declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
214
308
|
//#endregion
|
|
215
|
-
//#region src/extensions/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
declare function
|
|
309
|
+
//#region src/extensions/bullet-after-heading.d.ts
|
|
310
|
+
/**
|
|
311
|
+
* "Type a title, press Return, start bullets." When this extension is applied,
|
|
312
|
+
* pressing Enter at the end of the document's first heading (the title line)
|
|
313
|
+
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
314
|
+
*/
|
|
315
|
+
declare function defineBulletAfterHeading(): PlainExtension;
|
|
222
316
|
//#endregion
|
|
223
|
-
//#region src/extensions/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
declare function
|
|
240
|
-
|
|
241
|
-
|
|
317
|
+
//#region src/extensions/code-block-highlight.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Adds syntax highlighting to `codeBlock` nodes, parsing each block with the
|
|
320
|
+
* matching CodeMirror/Lezer grammar (loaded on demand from
|
|
321
|
+
* `@codemirror/language-data`). Tokens are tagged with `@lezer/highlight`
|
|
322
|
+
* `tok-*` classes; the default theme colors them per color scheme.
|
|
323
|
+
*/
|
|
324
|
+
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
325
|
+
/** A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes. */
|
|
326
|
+
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
327
|
+
/**
|
|
328
|
+
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
329
|
+
* editor's decorations use. Returns synchronously when the grammar is already
|
|
330
|
+
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
331
|
+
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
332
|
+
*/
|
|
333
|
+
declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/extensions/code-block-languages.d.ts
|
|
336
|
+
/**
|
|
337
|
+
* A list of languages for code block syntax-highlight.
|
|
338
|
+
*/
|
|
339
|
+
declare const codeBlockLanguages: ReadonlyArray<{
|
|
340
|
+
label: string;
|
|
341
|
+
value: string;
|
|
342
|
+
}>;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/extensions/embed-paste.d.ts
|
|
345
|
+
/**
|
|
346
|
+
* Auto-embed a pasted tweet or YouTube link. When the clipboard holds exactly
|
|
347
|
+
* one such URL, the link is rewritten to ``, which the image pipeline
|
|
348
|
+
* renders as a rich embed. Not part of `defineEditorExtension`; the React
|
|
349
|
+
* package applies it via the `embedPaste` prop (on by default).
|
|
350
|
+
*/
|
|
351
|
+
declare function defineEmbedPaste(): PlainExtension;
|
|
242
352
|
//#endregion
|
|
243
353
|
//#region src/extensions/embed/types.d.ts
|
|
244
354
|
/**
|
|
@@ -281,47 +391,16 @@ declare function listenForTweetHeight(iframe: HTMLIFrameElement): () => void;
|
|
|
281
391
|
/** Detect a tweet/YouTube embed in an image `src`, or `undefined` for a plain image. */
|
|
282
392
|
declare function matchEmbed(src: string): EmbedDescriptor | undefined;
|
|
283
393
|
//#endregion
|
|
284
|
-
//#region src/extensions/
|
|
285
|
-
/**
|
|
286
|
-
* Adds syntax highlighting to `codeBlock` nodes, parsing each block with the
|
|
287
|
-
* matching CodeMirror/Lezer grammar (loaded on demand from
|
|
288
|
-
* `@codemirror/language-data`). Tokens are tagged with `@lezer/highlight`
|
|
289
|
-
* `tok-*` classes; the default theme colors them per color scheme.
|
|
290
|
-
*/
|
|
291
|
-
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
292
|
-
/** A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes. */
|
|
293
|
-
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
294
|
-
/**
|
|
295
|
-
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
296
|
-
* editor's decorations use. Returns synchronously when the grammar is already
|
|
297
|
-
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
298
|
-
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
299
|
-
*/
|
|
300
|
-
declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/extensions/mark-chunk.d.ts
|
|
303
|
-
/**
|
|
304
|
-
* Contiguous range with a uniform inline-mark set.
|
|
305
|
-
*/
|
|
306
|
-
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/extensions/schema.d.ts
|
|
309
|
-
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
310
|
-
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
311
|
-
/** Typed mark builders bound to the shared schema. */
|
|
312
|
-
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/extensions/inline-text-to-mark-chunks.d.ts
|
|
394
|
+
//#region src/extensions/html-paste.d.ts
|
|
315
395
|
/**
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
396
|
+
* Paste foreign rich-text HTML as meowdown Markdown. Rewrites the clipboard's
|
|
397
|
+
* `text/html` through `transformPastedHTML`: foreign HTML is converted to a
|
|
398
|
+
* Markdown string, reparsed into meowdown nodes (literal source text, no marks),
|
|
399
|
+
* and re-serialized to HTML so ProseMirror's own clipboard parser inserts it with
|
|
400
|
+
* the right open depths. `<strong>bold</strong>` thus lands as the text `**bold**`,
|
|
401
|
+
* which the inline-mark plugin renders.
|
|
319
402
|
*/
|
|
320
|
-
declare function
|
|
321
|
-
|
|
322
|
-
marks: TypedMarkBuilders, /** The raw inline text of one textblock (no block prefix). */
|
|
323
|
-
|
|
324
|
-
text: string): MarkChunk[];
|
|
403
|
+
declare function defineHTMLPaste(): PlainExtension;
|
|
325
404
|
//#endregion
|
|
326
405
|
//#region src/extensions/image-click.d.ts
|
|
327
406
|
interface ImageClickPayload {
|
|
@@ -335,51 +414,43 @@ interface ImageClickPayload {
|
|
|
335
414
|
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
336
415
|
declare function defineImageClickHandler(onClick: ImageClickHandler): PlainExtension;
|
|
337
416
|
//#endregion
|
|
338
|
-
//#region src/extensions/
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
*/
|
|
356
|
-
declare function
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/extensions/markdown-copy.d.ts
|
|
359
|
-
/**
|
|
360
|
-
* Serialize copied/cut content to Markdown for the clipboard's `text/plain`, so
|
|
361
|
-
* pasting meowdown content into a plain-text field yields real Markdown (`- `
|
|
362
|
-
* list markers, blank-line block separation) instead of bare `textContent`.
|
|
363
|
-
*
|
|
364
|
-
* The copied fragment is wrapped in a `doc` so the existing block serializer can
|
|
365
|
-
* walk it. A purely inline fragment (a partial-paragraph copy) does not fit
|
|
366
|
-
* `doc`'s `block+` content, so it falls back to the inline text.
|
|
367
|
-
*/
|
|
368
|
-
declare function defineMarkdownCopy(): PlainExtension;
|
|
417
|
+
//#region src/extensions/image.d.ts
|
|
418
|
+
type ImageUrlResolver = (src: string) => string | undefined;
|
|
419
|
+
type ImagePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
420
|
+
type ImageSaveErrorHandler = (error: unknown, file: File) => void;
|
|
421
|
+
interface ImageOptions {
|
|
422
|
+
/**
|
|
423
|
+
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
424
|
+
* that image. Defaults to `defaultResolveImageUrl`.
|
|
425
|
+
*/
|
|
426
|
+
resolveImageUrl?: ImageUrlResolver;
|
|
427
|
+
/** Persist a pasted/dropped image file and return its markdown `src`, or `undefined` to decline. */
|
|
428
|
+
onImagePaste?: ImagePasteHandler;
|
|
429
|
+
/** Called when persisting a pasted/dropped image throws. Defaults to `console.error`. */
|
|
430
|
+
onImageSaveError?: ImageSaveErrorHandler;
|
|
431
|
+
}
|
|
432
|
+
/** Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it. */
|
|
433
|
+
declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
434
|
+
/** Inline image/embed rendering (a mark view) plus paste/drop persistence. */
|
|
435
|
+
declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
369
436
|
//#endregion
|
|
370
|
-
//#region src/extensions/
|
|
437
|
+
//#region src/extensions/mark-chunk.d.ts
|
|
371
438
|
/**
|
|
372
|
-
*
|
|
373
|
-
* pressing Enter at the end of the document's first heading (the title line)
|
|
374
|
-
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
439
|
+
* Contiguous range with a uniform inline-mark set.
|
|
375
440
|
*/
|
|
376
|
-
|
|
441
|
+
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
377
442
|
//#endregion
|
|
378
|
-
//#region src/extensions/
|
|
443
|
+
//#region src/extensions/inline-text-to-mark-chunks.d.ts
|
|
379
444
|
/**
|
|
380
|
-
*
|
|
445
|
+
* Walk a textblock's inline content and produce a list of mark chunks
|
|
446
|
+
* with positions relative to the start of `text` (i.e. zero-based).
|
|
447
|
+
* Callers shift the chunks into the document's coordinate space.
|
|
381
448
|
*/
|
|
382
|
-
declare function
|
|
449
|
+
declare function inlineTextToMarkChunks(/** Typed mark builders bound to the target schema. */
|
|
450
|
+
|
|
451
|
+
marks: TypedMarkBuilders, /** The raw inline text of one textblock (no block prefix). */
|
|
452
|
+
|
|
453
|
+
text: string): MarkChunk[];
|
|
383
454
|
//#endregion
|
|
384
455
|
//#region src/extensions/key-bindings.d.ts
|
|
385
456
|
/** Human-readable descriptions of the editor's formatting and heading shortcuts. */
|
|
@@ -388,6 +459,7 @@ declare const EDITOR_KEY_BINDINGS: {
|
|
|
388
459
|
readonly 'Mod-i': "Italic";
|
|
389
460
|
readonly 'Mod-e': "Inline code";
|
|
390
461
|
readonly 'Mod-Shift-x': "Strikethrough";
|
|
462
|
+
readonly 'Mod-Shift-h': "Highlight";
|
|
391
463
|
readonly 'Mod-1': "Heading 1";
|
|
392
464
|
readonly 'Mod-2': "Heading 2";
|
|
393
465
|
readonly 'Mod-3': "Heading 3";
|
|
@@ -396,89 +468,71 @@ declare const EDITOR_KEY_BINDINGS: {
|
|
|
396
468
|
readonly 'Mod-6': "Heading 6";
|
|
397
469
|
};
|
|
398
470
|
//#endregion
|
|
399
|
-
//#region src/extensions/
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
declare const codeBlockLanguages: ReadonlyArray<{
|
|
404
|
-
label: string;
|
|
405
|
-
value: string;
|
|
406
|
-
}>;
|
|
407
|
-
//#endregion
|
|
408
|
-
//#region src/converters/pm-to-md.d.ts
|
|
409
|
-
/** Options for {@link docToMarkdown}. */
|
|
410
|
-
interface DocToMarkdownOptions {
|
|
411
|
-
/** Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default. */
|
|
412
|
-
frontmatter?: boolean;
|
|
471
|
+
//#region src/extensions/link-click.d.ts
|
|
472
|
+
interface LinkClickPayload {
|
|
473
|
+
href: string;
|
|
474
|
+
event: MouseEvent;
|
|
413
475
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
*
|
|
417
|
-
* Performance design:
|
|
418
|
-
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
419
|
-
* Avoids per-block intermediate strings while keeping the
|
|
420
|
-
* function-per-node-type readability of a switch dispatch.
|
|
421
|
-
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
422
|
-
* restored via local variables across nested calls - no fresh
|
|
423
|
-
* context objects per recursion.
|
|
424
|
-
* - Inline content is walked directly (not via `node.textContent`) to
|
|
425
|
-
* skip one intermediate string allocation per leaf block.
|
|
426
|
-
* - Backtick fence width and cell escaping use single linear loops, no
|
|
427
|
-
* regex on the hot path.
|
|
428
|
-
*/
|
|
429
|
-
declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
476
|
+
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
477
|
+
declare function defineLinkClickHandler(onClick: LinkClickHandler): PlainExtension;
|
|
430
478
|
//#endregion
|
|
431
|
-
//#region src/
|
|
432
|
-
/** Options for {@link markdownToDoc}. */
|
|
433
|
-
interface MarkdownToDocOptions {
|
|
434
|
-
/** Node builders to build the document with. Defaults to the shared schema's builders. */
|
|
435
|
-
nodes?: TypedNodeBuilders;
|
|
436
|
-
/** Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default. */
|
|
437
|
-
frontmatter?: boolean;
|
|
438
|
-
}
|
|
479
|
+
//#region src/extensions/mark-mode.d.ts
|
|
439
480
|
/**
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
* By default the document is built with the shared schema's node builders, so
|
|
443
|
-
* no editor is required. When the result will be loaded into a specific editor,
|
|
444
|
-
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
445
|
-
* instance and can be inserted without a JSON round trip.
|
|
481
|
+
* Controls how markdown syntax characters are rendered and how the
|
|
482
|
+
* editor serializes content to the clipboard.
|
|
446
483
|
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* inline marks because the markdown stays literal text - emphasis / link /
|
|
451
|
-
* inline-code characters survive verbatim.
|
|
484
|
+
* - 'hide': syntax chars never visible; copy strips them.
|
|
485
|
+
* - 'focus': syntax chars hidden by default; revealed near cursor; copy strips them.
|
|
486
|
+
* - 'show': syntax chars always visible (dim grey); copy keeps them.
|
|
452
487
|
*/
|
|
453
|
-
|
|
488
|
+
type MarkMode = 'hide' | 'focus' | 'show';
|
|
489
|
+
declare function defineMarkMode(mode: MarkMode): PlainExtension;
|
|
454
490
|
//#endregion
|
|
455
|
-
//#region src/
|
|
491
|
+
//#region src/extensions/mark-names.d.ts
|
|
492
|
+
declare const MARK_NAMES: readonly ["mdImageView", "mdImageSource", "mdMark", "mdEm", "mdStrong", "mdCode", "mdLinkText", "mdLinkUri", "mdDel", "mdHighlight", "mdTag", "mdWikilinkSource", "mdWikilinkView", "mdPack"];
|
|
493
|
+
type MarkName = (typeof MARK_NAMES)[number];
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/extensions/markdown-copy.d.ts
|
|
456
496
|
/**
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
497
|
+
* Serialize copied/cut content to Markdown for the clipboard's `text/plain`, so
|
|
498
|
+
* pasting meowdown content into a plain-text field yields real Markdown (`- `
|
|
499
|
+
* list markers, blank-line block separation) instead of bare `textContent`.
|
|
500
|
+
*
|
|
501
|
+
* The copied fragment is wrapped in a `doc` so the existing block serializer can
|
|
502
|
+
* walk it. A purely inline fragment (a partial-paragraph copy) does not fit
|
|
503
|
+
* `doc`'s `block+` content, so it falls back to the inline text.
|
|
463
504
|
*/
|
|
464
|
-
|
|
465
|
-
/** Options for {@link checkRoundTrip}. */
|
|
466
|
-
interface CheckRoundTripOptions {
|
|
467
|
-
/** Whether to handle a leading `---` frontmatter block. Off by default. */
|
|
468
|
-
frontmatter?: boolean;
|
|
469
|
-
}
|
|
470
|
-
/** Classify how `markdown` survives the editor's parse-then-serialize round trip. */
|
|
471
|
-
declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
505
|
+
declare function defineMarkdownCopy(): PlainExtension;
|
|
472
506
|
//#endregion
|
|
473
507
|
//#region src/extensions/node-names.d.ts
|
|
474
508
|
/**
|
|
475
509
|
* Every ProseMirror node name the editor schema knows about.
|
|
476
510
|
*/
|
|
477
|
-
declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "blockquote", "list", "codeBlock", "horizontalRule", "table", "tableRow", "tableCell", "tableHeaderCell"];
|
|
511
|
+
declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "blockquote", "list", "codeBlock", "horizontalRule", "htmlComment", "table", "tableRow", "tableCell", "tableHeaderCell"];
|
|
478
512
|
type NodeName = (typeof NODE_NAMES)[number];
|
|
479
513
|
//#endregion
|
|
480
|
-
//#region src/extensions/
|
|
481
|
-
|
|
482
|
-
|
|
514
|
+
//#region src/extensions/tag-click.d.ts
|
|
515
|
+
interface TagClickPayload {
|
|
516
|
+
/** The tag name, without the leading `#`. */
|
|
517
|
+
tag: string;
|
|
518
|
+
/** The originating click. Read modifier keys or position a popover from it. */
|
|
519
|
+
event: MouseEvent;
|
|
520
|
+
}
|
|
521
|
+
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
522
|
+
declare function defineTagClickHandler(onClick: TagClickHandler): PlainExtension;
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/extensions/wikilink-click.d.ts
|
|
525
|
+
interface WikilinkClickPayload {
|
|
526
|
+
target: string;
|
|
527
|
+
event: MouseEvent;
|
|
528
|
+
}
|
|
529
|
+
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
530
|
+
declare function defineWikilinkClickHandler(onClick: WikilinkClickHandler): PlainExtension;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/extensions/wikilink-trigger.d.ts
|
|
533
|
+
/**
|
|
534
|
+
* Binds `Mod-Shift-k` to open the wikilink menu.
|
|
535
|
+
*/
|
|
536
|
+
declare function defineWikilinkTrigger(): PlainExtension;
|
|
483
537
|
//#endregion
|
|
484
|
-
export { type CheckRoundTripOptions, type CodeBlockAttrs, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EmbedDescriptor, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type LinkClickHandler, type LinkClickPayload, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdImageViewAttrs, type MdLinkTextAttrs, type MdWikilinkViewAttrs, type NodeName, type PlaceholderOptions, Priority, type RoundTripFidelity, type TypedEditor, type TypedMarkBuilders, type WikilinkClickHandler, type WikilinkClickPayload, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, inlineTextToMarkChunks, listenForTweetHeight, markdownToDoc, matchEmbed, withPriority };
|
|
538
|
+
export { type CheckRoundTripOptions, type CodeBlockAttrs, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EmbedDescriptor, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type LinkClickHandler, type LinkClickPayload, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdImageViewAttrs, type MdLinkTextAttrs, type MdWikilinkViewAttrs, type MeowdownHTMLCommentAttrs, type NodeName, type PlaceholderOptions, Priority, type RoundTripFidelity, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type WikilinkClickHandler, type WikilinkClickPayload, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, inlineTextToMarkChunks, listenForTweetHeight, markdownToDoc, matchEmbed, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineHistory as s,defineKeymap as c,defineMarkSpec as l,defineMarkView as u,defineNodeAttr as d,defineNodeSpec as f,definePlugin as p,getMarkRange as m,getMarkType as ee,getNodeType as te,
|
|
2
|
-
`)}function ht(e){let{selection:t}=e;if(!t.empty)return b.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return b.empty;let i=m(n,ee(e.schema,`mdPack`));return i?b.create(e.doc,[_e.inline(i.from,i.to,{class:`show`})]):b.empty}function T(e,t){let n=pt(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function E(e,t,n){for(let r of n){let n=w(e,t,r);if(n)return n}}function D(e,t,n){let r=E(e,t,n);return r&&r.to===t?r:void 0}function O(e,t,n){let r=E(e,t,n);return r&&r.from===t?r:void 0}function k(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=E(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function gt(e,t){return y.create(e.doc,t.from,t.to)}function _t(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!ie(t.selection))return!1;let i=t.selection;if(i.empty){let e=O(t,i.from,r);if(e)return n?.(t.tr.setSelection(gt(t,e))),!0;if(D(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(y.create(t.doc,i.from+1))),!0)}return!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(y.create(t.doc,a.to))),!0):!1}}function vt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!ie(t.selection))return!1;let i=t.selection;if(i.empty){let e=D(t,i.from,r);return e?(n?.(t.tr.setSelection(gt(t,e))),!0):!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(y.create(t.doc,a.from))),!0):!1}}function yt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=D(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!O(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function bt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=O(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!D(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}function xt(e,t){return new _({key:new v(`atomic-mark-selection-${t}`),props:{decorations:n=>{let r=T(e,n);if(r.length===0)return;let i=k(n,r);if(i)return b.create(n.doc,[_e.inline(i.from,i.to,{class:t})])}}})}function St({marks:e,selectedClass:n}){return h(g(c({ArrowRight:_t(e),ArrowLeft:vt(e),Backspace:yt(e),Delete:bt(e)}),t.high),p(xt(e,n)))}const A=new Map,Ct=new Map;async function wt(e){let t=A.get(e);if(t!==void 0)return t;let n=ve.matchLanguageName(ye,e,!0);if(!n)return A.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),A.set(e,null),null}return A.set(e,r),r}function Tt(e,t){let n=Ct.get(e);if(n)return n;let r=Se({parse:e=>t.language.parser.parse(e.content),highlighter:be});return Ct.set(e,r),r}const Et=e=>{let t=e.language?.trim();if(!t)return[];let n=A.get(t);return n===null?[]:n?Tt(t,n)(e):wt(t).then(()=>void 0)};function Dt(){return de({parser:Et,nodeTypes:[`codeBlock`]})}function Ot(e,t){let n=t.language.parser.parse(e),r=[];return xe(n,be,(e,t,n)=>{r.push([e,t,n])}),r}function kt(e,t){let n=t.trim();if(!n)return[];let r=A.get(n);return r===null?[]:r?Ot(e,r):wt(n).then(t=>t?Ot(e,t):[])}function At(){return d({type:`doc`,attr:`frontmatter`,default:null})}function jt(){return f({name:`heading`,whitespace:`pre`})}function Mt(){return d({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function j(e){return ce(ae({type:`heading`,attrs:{level:e}}))}const Nt=(e,t,n)=>re(e,n)?.parent.type.name===`heading`?oe()(e,t,n):!1;function Pt(){return c({"Mod-1":j(1),"Mod-2":j(2),"Mod-3":j(3),"Mod-4":j(4),"Mod-5":j(5),"Mod-6":j(6),Backspace:Nt})}function Ft(){return h(Te(),jt(),Mt(),we(),Ce(),Pt())}function It(){return d({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function Lt(){return h(Ee(),It())}function Rt(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function zt(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Me.fromJSON(e,t))]}var M=class e extends Oe{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return ke.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new Ae(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new Ae(e),n.addMark(i,c,t));return!1})}return ke.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Bt;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new De(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Rt)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>zt(t,e)))}};Oe.jsonID(`batchSetMark`,M);const Bt=new M([]),Vt=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Ht=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Ut(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Wt(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Vt.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Ht.test(e))return!1;return!0}function Gt(e){return e===32||e===9||e===10||e===13}const Kt=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,qt=/[\s(*_~]/;function Jt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Yt(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Xt(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Yt(e,t,`)`)>Yt(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const Zt={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Jt(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!qt.test(r))return-1;let i=Kt.exec(e.slice(n,e.end));if(!i)return-1;let a=Xt(i[0]);return a===0||!Wt(Ut(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Qt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function $t(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const en={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!Qt(t))break;i||=$t(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},tn={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function nn(e){return e.end}const N=Pe.configure([Ne,en,tn,Zt]),rn=N.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:nn}]});function P(e){return N.parseInline(e,0)}function F(e,t,n=[]){for(let r of e)t(r)&&n.push(r),F(r.children,t,n);return n}function an(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const I=an(N);function on(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function sn(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function cn(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view`;let r=document.createElement(`span`);r.className=`md-wikilink-label`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,r.textContent=t.display||t.target,n.appendChild(r);let i=document.createElement(`span`);return i.className=`md-wikilink-view-content`,n.appendChild(i),{dom:n,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function ln(){return u({name:`mdWikilinkView`,constructor:cn()})}const L=new Map([[I.Emphasis,`mdEm`],[I.StrongEmphasis,`mdStrong`],[I.InlineCode,`mdCode`],[I.Strikethrough,`mdDel`],[I.EmphasisMark,`mdMark`],[I.CodeMark,`mdMark`],[I.LinkMark,`mdMark`],[I.StrikethroughMark,`mdMark`],[I.URL,`mdLinkUri`],[I.Hashtag,`mdTag`],[I.WikilinkMark,`mdMark`]]);function un(e,t){let n=P(t),r=[];return R(n,[],0,t.length,t,e,r),r}function dn(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||Wt(Ut(e)))return`https://${e}`}function R(e,t,n,r,i,a,o){let s=n;for(let n of e){n.from>s&&z(o,s,n.from,t);let e=n.type;if(e===I.Link)fn(n,t,i,a,o);else if(e===I.Image)pn(n,t,i,a,o);else if(e===I.Wikilink)mn(n,t,i,a,o);else if(e===I.URL){let e=dn(i.slice(n.from,n.to)),r=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();z(o,n.from,n.to,[...t,r])}else{let r;e===I.Emphasis?r=`italic`:e===I.StrongEmphasis?r=`bold`:e===I.InlineCode?r=`code`:e===I.Strikethrough?r=`strike`:e===I.Autolink&&(r=`autolink`);let s=r?[...t,a.mdPack.create({key:r})]:t,c=L.get(e),l=c?[...s,a[c].create()]:s;n.children.length===0?z(o,n.from,n.to,l):R(n.children,l,n.from,n.to,i,a,o)}s=n.to}s<r&&z(o,s,r,t)}function fn(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===I.LinkMark?(s++,s===2&&(a=t.from)):t.type===I.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c?r.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=r.mdPack.create({key:`link_${c}`}),f=[...t,d],p=e.from;for(let t of e.children){if(t.from>p){let e=u(p)?[...f,l]:f;z(i,p,t.from,e)}let e=u(t.from)?[...f,l]:f;if(t.type===I.Wikilink){mn(t,e,n,r,i),p=t.to;continue}let a=L.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?z(i,t.from,t.to,o):R(t.children,o,t.from,t.to,n,r,i),p=t.to}p<e.to&&z(i,p,e.to,f)}function pn(e,t,n,r,i){let a=e.children.find(e=>e.type===I.URL);if(!a){fn(e,t,n,r,i);return}let o=e.children.filter(e=>e.type===I.LinkMark),s=n.slice(a.from,a.to),c=o.length>=2?n.slice(o[0].to,o[1].from):``,l=r.mdImageSource.create({src:s,alt:c}),u=r.mdImageView.create({src:s,alt:c}),d=r.mdPack.create({key:`image_${s}`}),f=e.to-1,p=e=>e>=f?[...t,d,l,u]:[...t,d,l],m=e.from;for(let t of e.children){t.from>m&&z(i,m,t.from,p(m));let e=L.get(t.type),a=e?[...p(t.from),r[e].create()]:p(t.from);t.children.length===0?z(i,t.from,t.to,a):R(t.children,a,t.from,t.to,n,r,i),m=t.to}m<e.to&&z(i,m,e.to,p(m))}function mn(e,t,n,r,i){let{target:a,display:o}=sn(n.slice(e.from,e.to)),s=r.mdWikilinkSource.create({target:a}),c=r.mdWikilinkView.create({target:a,display:o}),l=e.to-1,u=e=>e>=l?[...t,s,c]:[...t,s],d=e.from;for(let t of e.children){t.from>d&&z(i,d,t.from,u(d));let e=r.mdMark.create();t.from<l&&t.to>l?(z(i,t.from,l,[...u(t.from),e]),z(i,l,t.to,[...u(l),e])):z(i,t.from,t.to,[...u(t.from),e]),d=t.to}d<e.to&&z(i,d,e.to,u(d))}function z(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&on(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const hn=x(()=>{let e=Or().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),gn=x(()=>r(hn())),_n=x(()=>n(hn())),vn=`meowdown_mark_builders`;function yn(e){let t=e.cached[vn];if(t)return t;let r=n(e);return e.cached[vn]=r,r}const bn=`meowdown_node_builders`;function xn(e){let t=e.cached[bn];if(t)return t;let n=r(e);return e.cached[bn]=n,n}const Sn=`inline-marks-applied`,Cn=new WeakMap;let wn=0,Tn=0;function En(e,t,n){let r=Cn.get(e);if(r?Tn++:(wn++,r=un(yn(n),e.textContent),Cn.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function Dn(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function On(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=En(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function kn(){return new _({key:new v(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Sn))return null;let r=On(n,Dn(e,n));if(r.length===0)return null;let i=n.tr.step(new M(r));return i.setMeta(Sn,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(An(e.state)),{}}})}function An(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function jn(){return p(kn())}function Mn(){return l({name:`mdImageView`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-anchor`},0],parseDOM:[{tag:`span.md-image-anchor`}]})}function Nn(){return l({name:`mdImageSource`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-source`},0],parseDOM:[{tag:`span.md-image-source`}]})}function Pn(){return l({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Fn(){return l({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function In(){return l({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Ln(){return l({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Rn(){return l({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function zn(){return l({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Bn(){return l({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Vn(){return l({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Hn(){return l({name:`mdWikilinkSource`,inclusive:!1,attrs:{target:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-source`},0],parseDOM:[{tag:`span.md-wikilink-source`}]})}function Un(){return l({name:`mdWikilinkView`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-anchor`},0],parseDOM:[{tag:`span.md-wikilink-anchor`}]})}function Wn(){return l({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{default:``}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Gn(){return h(Pn(),Fn(),In(),Ln(),Rn(),zn(),Bn(),Vn(),Hn(),Un(),Nn(),Mn(),Wn())}function Kn(e,t=0){let n=t,r=0;for(let t=0;t<e.length;t++)e.charCodeAt(t)===96?(r++,r>n&&(n=r)):r=0;return n}const B={em:{node:I.Emphasis,delim:`*`},strong:{node:I.StrongEmphasis,delim:`**`},code:{node:I.InlineCode,delim:"`"},del:{node:I.Strikethrough,delim:`~~`}},qn=new Set([I.EmphasisMark,I.CodeMark,I.LinkMark,I.StrikethroughMark]);function V(e){return[e.children[0],e.children.at(-1)]}function Jn(e){let{type:t,children:n}=e;if(t===I.Emphasis||t===I.StrongEmphasis||t===I.Strikethrough)return[n[0].to,n.at(-1).from];if(t===I.Link||t===I.Image){let e=n.find((e,t)=>t>0&&e.type===I.LinkMark);return e?[n[0].to,e.from]:null}return null}function H(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Jn(r);return i&&i[0]<=t&&n<=i[1]?H(r.children,t,n):H(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Yn(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Yn(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}const U=e=>e===` `||e===` `;function Xn(e,t,n){for(;t<n&&U(e[t]);)t++;for(;n>t&&U(e[n-1]);)n--;return[t,n]}function Zn(e,t,n,r){let i=F(P(e),e=>e.type===r.node||qn.has(e.type));for(let r=t;r<n;r++)if(!U(e[r])&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Qn(e,t,n,r,i){let a=P(e),o=F(a,e=>e.type===r.node);return i?tr(e,o,t,n):$n(e,a,o,t,n,r)}function $n(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=H(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=V(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=er(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function er(e,t,n,r,i){if(i.node!==I.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(Kn(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function tr(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=V(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Yn(a.children.slice(1,-1),s,c);s>t.to&&U(e[s-1]);)s--;for(;c<o.from&&U(e[c]);)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function nr(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=P(e),o=F(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=V(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return rr(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function rr(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Jn(n);return!e||t<e[0]||t>e[1]?!0:rr(n.children,t)}return!1}function W(e){return(t,n)=>{if(t.selection.empty)return ir(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=Xn(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Zn(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Qn(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(y.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function ir(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=nr(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(y.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(y.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function ar(){return o({toggleEm:()=>W(B.em),toggleStrong:()=>W(B.strong),toggleCode:()=>W(B.code),toggleDel:()=>W(B.del)})}function or(){return c({"Mod-b":W(B.strong),"Mod-i":W(B.em),"Mod-e":W(B.code),"Mod-Shift-x":W(B.del)})}function sr(){return h(ar(),or())}function cr(){return d({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function lr(){return d({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function ur(e){return e===2||e===3||e===4}function dr(){return d({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>ur(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return ur(t)?t:1}})}const fr=[C(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),C(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),C(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),C(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function pr(){return h(fr.map(Fe))}function mr(){return S({kind:`task`,marker:`+`})}function hr(){return S({kind:`task`,marker:null})}function gr(){return o({wrapInCircleTask:mr,wrapInSquareTask:hr})}function _r(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function vr(){return(e,t,n)=>{let r=_r(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},S(a)(e,t,n)}}function yr(){return(e,t,n)=>{let r=_r(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},S(a)(e,t,n)}}function br(){return c({"Mod-Enter":vr(),"Mod-Shift-Enter":yr()})}function xr(){return h(Ve(),ze(),Re(),Ie(),Be(),Le(),pr(),br(),cr(),lr(),dr(),gr())}function Sr(){return f({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function Cr(){return h(g(Sr(),t.highest),He(),Ue())}const wr=(e,t)=>{let{selection:n}=e;return!Qe(n)||!n.isColSelection()||!n.isRowSelection()?!1:Ze(e,t)};function Tr(){return g(c({Backspace:wr,Delete:wr}),t.high)}function Er(){return h(Xe(),Ye(),We(),Je(),qe({allowTableNodeSelection:!0}),Ge(),Ke(),Tr())}function Dr(){return h(Cr(),fe(),At(),he(),le(),xr(),Ft(),Er(),ue(),Lt(),Gn(),Dt(),jn(),sr(),ln(),St({marks:[{name:`mdImageSource`,modes:[`hide`]},{name:`mdWikilinkSource`,modes:[`hide`,`focus`,`show`]}],selectedClass:`md-atomic-selected`}),a(),i(),s(),pe(),ge(),me())}function Or(){return Dr()}function kr(e){let t;return p(new _({key:e.key,props:{handleDOMEvents:{mousedown:e=>{let{from:n,to:r,empty:i}=e.state.selection;return t={from:n,to:r,empty:i},!1}},handleClick:(n,r,i)=>{if(!i.target?.closest?.(e.selector))return!1;let a=e.findHitAt(n.state,r);return!a||!(ne?i.metaKey:i.ctrlKey)&&t?.empty&&t.from>=a.from&&t.to<=a.to?!1:(e.preventDefault&&i.preventDefault(),e.onClick(a.payload,i),!0)}}}))}const Ar=new v(`meowdown-wikilink-click`);function jr(e,t){let n=w(e,t,`mdWikilinkSource`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Mr(e){return kr({key:Ar,selector:`.md-wikilink-label, .md-wikilink-source`,preventDefault:!1,findHitAt:(e,t)=>{let n=jr(e,t);return n?{from:n.from,to:n.to,payload:n.target}:void 0},onClick:(t,n)=>e({target:t,event:n})})}const Nr=new v(`meowdown-link-click`);function Pr(e,t){let n=w(e,t,`mdLinkText`);if(n)return{from:n.from,to:n.to,href:n.mark.attrs.href}}function Fr(e){return kr({key:Nr,selector:`.md-link`,preventDefault:!0,findHitAt:(e,t)=>{let n=Pr(e,t);return n?{from:n.from,to:n.to,payload:n.href}:void 0},onClick:(t,n)=>e({href:t,event:n})})}function Ir(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Lr=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Rr=/\/status(?:es)?\/(\d+)/;function zr(e){let t;try{t=new URL(e)}catch{return}if(Lr.test(t.hostname))return Rr.exec(t.pathname)?.[1]}const Br=e=>{let t=zr(e);if(!t)return;let n=Ir()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function Vr(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const Hr=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Ur=/^(?:www\.)?youtu\.be$/i,Wr=/^[\w-]{11}$/;function Gr(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Ur.test(t.hostname))n=t.pathname.slice(1);else if(Hr.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!Wr.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Kr(r):void 0;return{videoId:n,startSeconds:i}}function Kr(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const qr=[e=>{let t=Gr(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},Br];function G(e){for(let t of qr){let n=t(e);if(n)return n}}function Jr(e){return/^https?:\/\//i.test(e)?e:void 0}function Yr(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&Vr(t),t}function Xr(e,t,n){let r=G(e);if(r){let e=document.createElement(`span`);return e.className=`md-image-preview md-image-preview-embed`,e.appendChild(Yr(r)),e}let i=(n.resolveImageUrl??Jr)(e);if(!i)return;let a=document.createElement(`span`);a.className=`md-image-preview md-image-preview-img`,a.dataset.testid=`image-preview`;let o=document.createElement(`img`);return o.src=i,o.alt=t,o.draggable=!1,a.appendChild(o),a}function Zr(e){return t=>{let n=t.attrs,r=document.createElement(`span`);r.className=`md-image-view`;let i=document.createElement(`span`);i.className=`md-image-view-content`,r.appendChild(i);let a=Xr(n.src,n.alt,e);return a&&(a.contentEditable=`false`,r.appendChild(a)),{dom:r,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function Qr(e){return e?Array.from(e.files).filter(e=>e.type.startsWith(`image/`)):[]}const $r=e=>{console.error(`[meowdown] failed to save pasted image:`,e)};async function ei(e,t,n,r=$r,i){let a=i;for(let i of t){let t;try{t=await n(i)}catch(e){r(e,i);continue}if(!t||e.isDestroyed)continue;let o=``,s=a==null?e.state.tr.insertText(o):e.state.tr.insertText(o,a);e.dispatch(s),a!=null&&(a+=o.length)}}function ti(e){return new _({key:new v(`image-input`),props:{handlePaste:(t,n)=>{let r=Qr(n.clipboardData),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(ei(t,r,i,a),!0)},handleDrop:(t,n)=>{let r=Qr(n.dataTransfer),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(ei(t,r,i,a,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function ni(e={}){return h(u({name:`mdImageView`,constructor:Zr(e)}),g(p(ti(e)),t.high))}const ri=new v(`meowdown-image-click`);function ii(e,t){let n=w(e,t,`mdImageSource`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function ai(e){return p(new _({key:ri,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=ii(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}const oi=new v(`meowdown-embed-paste`);function si(e){let t=e.trim();if(!(!t||/\s/.test(t)))return G(t)?t:void 0}function ci(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
3
|
-
|
|
4
|
-
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function vi(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function yi(e,t){return t===0||!e.includes(`
|
|
1
|
+
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineHistory as s,defineKeymap as c,defineMarkSpec as l,defineMarkView as u,defineNodeAttr as d,defineNodeSpec as f,definePlugin as p,getMarkRange as m,getMarkType as ee,getNodeType as te,isAtBlockStart as ne,isTextSelection as re,toggleNode as ie,union as h,unsetBlockType as ae,withPriority as oe,withPriority as g,withSkipCodeBlock as se}from"@prosekit/core";import{definePlaceholder as ce}from"@prosekit/extensions/placeholder";import{defineReadonly as le}from"@prosekit/extensions/readonly";import{once as _}from"@ocavue/utils";import{defineBlockquote as ue}from"@prosekit/extensions/blockquote";import{defineCodeBlock as de,defineCodeBlockHighlight as fe}from"@prosekit/extensions/code-block";import{defineDoc as pe}from"@prosekit/extensions/doc";import{defineGapCursor as me}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as he}from"@prosekit/extensions/mod-click-prevention";import{defineText as ge}from"@prosekit/extensions/text";import{defineVirtualSelection as _e}from"@prosekit/extensions/virtual-selection";import{Plugin as v,PluginKey as y,TextSelection as b}from"@prosekit/pm/state";import{Decoration as ve,DecorationSet as x}from"@prosekit/pm/view";import{LanguageDescription as ye}from"@codemirror/language";import{languages as be}from"@codemirror/language-data";import{classHighlighter as xe,highlightTree as Se}from"@lezer/highlight";import{createParser as Ce}from"prosemirror-highlight/lezer";import{defineHeadingCommands as we,defineHeadingInputRule as Te,defineHeadingSpec as Ee}from"@prosekit/extensions/heading";import{defineHorizontalRule as De}from"@prosekit/extensions/horizontal-rule";import{ReplaceStep as Oe,Step as ke,StepResult as Ae,Transform as je}from"@prosekit/pm/transform";import{DOMSerializer as Me,Mark as Ne}from"@prosekit/pm/model";import{GFM as Pe,parser as Fe}from"@lezer/markdown";import{defineInputRule as Ie}from"@prosekit/extensions/input-rule";import{defineListCommands as Le,defineListDropIndicator as Re,defineListKeymap as ze,defineListPlugins as Be,defineListSerializer as Ve,defineListSpec as He,wrapInList as S}from"@prosekit/extensions/list";import{wrappingListInputRule as C}from"prosemirror-flat-list";import{defineParagraphCommands as Ue,defineParagraphKeymap as We}from"@prosekit/extensions/paragraph";import{defineTableCellSpec as Ge,defineTableCommands as Ke,defineTableDropIndicator as qe,defineTableEditingPlugin as Je,defineTableHeaderCellSpec as Ye,defineTableRowSpec as Xe,defineTableSpec as Ze,deleteTable as Qe,isCellSelection as $e}from"@prosekit/extensions/table";import{closeHistory as et}from"@prosekit/pm/history";import tt from"rehype-parse";import nt from"rehype-remark";import rt from"remark-gfm";import it from"remark-stringify";import{unified as at}from"unified";import{triggerAutocomplete as ot}from"@prosekit/extensions/autocomplete";function w(e,t,n){let r=e.doc.content.size;if(t<0||t>r)return;let i=e.doc.resolve(t);if(!(!i.parent.isTextblock||i.parent.type.spec.code))return m(i,n)}const st=new Set([`mdMark`,`mdLinkUri`]),ct=new Set([`mdImageSource`,`mdWikilinkSource`]),lt=new y(`mark-mode`);function ut(e){return new v({key:lt,state:{init:()=>e,apply:(e,t)=>t},props:{attributes:{"data-mark-mode":e},decorations:e===`focus`?e=>mt(e):void 0,clipboardTextSerializer:e===`show`?void 0:pt}})}function dt(e){return p(ut(e))}function ft(e){return lt.getState(e)}function pt(e){let t=[];return e.content.forEach(e=>{let n=[];e.descendants(e=>!e.isText||!e.text?!0:(!e.marks.some(e=>ct.has(e.type.name))&&e.marks.some(e=>st.has(e.type.name))||n.push(e.text),!1)),t.push(n.join(``))}),t.join(`
|
|
2
|
+
`)}function mt(e){let{selection:t}=e;if(!t.empty)return x.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return x.empty;let i=m(n,ee(e.schema,`mdPack`));return i?x.create(e.doc,[ve.inline(i.from,i.to,{class:`show`})]):x.empty}function T(e,t){let n=ft(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function E(e,t,n){for(let r of n){let n=w(e,t,r);if(n)return n}}function D(e,t,n){let r=E(e,t,n);return r&&r.to===t?r:void 0}function O(e,t,n){let r=E(e,t,n);return r&&r.from===t?r:void 0}function k(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=E(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function ht(e,t){return b.create(e.doc,t.from,t.to)}function gt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!re(t.selection))return!1;let i=t.selection;if(i.empty){let e=O(t,i.from,r);if(e)return n?.(t.tr.setSelection(ht(t,e))),!0;if(D(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(b.create(t.doc,i.from+1))),!0)}return!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(b.create(t.doc,a.to))),!0):!1}}function _t(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!re(t.selection))return!1;let i=t.selection;if(i.empty){let e=D(t,i.from,r);return e?(n?.(t.tr.setSelection(ht(t,e))),!0):!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(b.create(t.doc,a.from))),!0):!1}}function vt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=D(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!O(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function yt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=O(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!D(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}function bt(e,t){return new v({key:new y(`atomic-mark-selection-${t}`),props:{decorations:n=>{let r=T(e,n);if(r.length===0)return;let i=k(n,r);if(i)return x.create(n.doc,[ve.inline(i.from,i.to,{class:t})])}}})}function xt({marks:e,selectedClass:n}){return h(g(c({ArrowRight:gt(e),ArrowLeft:_t(e),Backspace:vt(e),Delete:yt(e)}),t.high),p(bt(e,n)))}const A=new Map,St=new Map;async function Ct(e){let t=A.get(e);if(t!==void 0)return t;let n=ye.matchLanguageName(be,e,!0);if(!n)return A.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),A.set(e,null),null}return A.set(e,r),r}function wt(e,t){let n=St.get(e);if(n)return n;let r=Ce({parse:e=>t.language.parser.parse(e.content),highlighter:xe});return St.set(e,r),r}const Tt=e=>{let t=e.language?.trim();if(!t)return[];let n=A.get(t);return n===null?[]:n?wt(t,n)(e):Ct(t).then(()=>void 0)};function Et(){return fe({parser:Tt,nodeTypes:[`codeBlock`]})}function Dt(e,t){let n=t.language.parser.parse(e),r=[];return Se(n,xe,(e,t,n)=>{r.push([e,t,n])}),r}function Ot(e,t){let n=t.trim();if(!n)return[];let r=A.get(n);return r===null?[]:r?Dt(e,r):Ct(n).then(t=>t?Dt(e,t):[])}function kt(){return d({type:`doc`,attr:`frontmatter`,default:null})}function At(){return f({name:`heading`,whitespace:`pre`})}function jt(){return d({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function j(e){return se(ie({type:`heading`,attrs:{level:e}}))}const Mt=(e,t,n)=>ne(e,n)?.parent.type.name===`heading`?ae()(e,t,n):!1;function Nt(){return c({"Mod-1":j(1),"Mod-2":j(2),"Mod-3":j(3),"Mod-4":j(4),"Mod-5":j(5),"Mod-6":j(6),Backspace:Mt})}function Pt(){return h(Ee(),At(),jt(),Te(),we(),Nt())}function Ft(){return d({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function It(){return h(De(),Ft())}function Lt(){return f({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function Rt(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function zt(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ne.fromJSON(e,t))]}var M=class e extends ke{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return Ae.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new je(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new je(e),n.addMark(i,c,t));return!1})}return Ae.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Bt;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new Oe(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Rt)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>zt(t,e)))}};ke.jsonID(`batchSetMark`,M);const Bt=new M([]),Vt=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Ht=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Ut(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Wt(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Vt.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Ht.test(e))return!1;return!0}function Gt(e){return e===32||e===9||e===10||e===13}const Kt=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,qt=/[\s(*_~]/;function Jt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Yt(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Xt(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Yt(e,t,`)`)>Yt(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const Zt={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Jt(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!qt.test(r))return-1;let i=Kt.exec(e.slice(n,e.end));if(!i)return-1;let a=Xt(i[0]);return a===0||!Wt(Ut(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Qt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function $t(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const en={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!Qt(t))break;i||=$t(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},tn={resolve:`Highlight`,mark:`HighlightMark`},nn=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,rn={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=nn.test(r),c=nn.test(i);return e.addDelimiter(tn,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]},an={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function on(e){return e.end}const N=Fe.configure([Pe,en,an,Zt,rn]),sn=N.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:on}]});function P(e){return N.parseInline(e,0)}function F(e,t,n=[]){for(let r of e)t(r)&&n.push(r),F(r.children,t,n);return n}function cn(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const I=cn(N);function ln(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function un(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function dn(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view`;let r=document.createElement(`span`);r.className=`md-wikilink-label`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,r.textContent=t.display||t.target,n.appendChild(r);let i=document.createElement(`span`);return i.className=`md-wikilink-view-content`,n.appendChild(i),{dom:n,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function fn(){return u({name:`mdWikilinkView`,constructor:dn()})}const L=new Map([[I.Emphasis,`mdEm`],[I.StrongEmphasis,`mdStrong`],[I.InlineCode,`mdCode`],[I.Strikethrough,`mdDel`],[I.Highlight,`mdHighlight`],[I.EmphasisMark,`mdMark`],[I.CodeMark,`mdMark`],[I.LinkMark,`mdMark`],[I.StrikethroughMark,`mdMark`],[I.HighlightMark,`mdMark`],[I.URL,`mdLinkUri`],[I.Hashtag,`mdTag`],[I.WikilinkMark,`mdMark`]]);function pn(e,t){let n=P(t),r=[];return R(n,[],0,t.length,t,e,r),r}function mn(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||Wt(Ut(e)))return`https://${e}`}function R(e,t,n,r,i,a,o){let s=n;for(let n of e){n.from>s&&z(o,s,n.from,t);let e=n.type;if(e===I.Link)hn(n,t,i,a,o);else if(e===I.Image)gn(n,t,i,a,o);else if(e===I.Wikilink)_n(n,t,i,a,o);else if(e===I.URL){let e=mn(i.slice(n.from,n.to)),r=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();z(o,n.from,n.to,[...t,r])}else{let r;e===I.Emphasis?r=`italic`:e===I.StrongEmphasis?r=`bold`:e===I.InlineCode?r=`code`:e===I.Strikethrough?r=`strike`:e===I.Highlight?r=`highlight`:e===I.Autolink&&(r=`autolink`);let s=r?[...t,a.mdPack.create({key:r})]:t,c=L.get(e),l=c?[...s,a[c].create()]:s;n.children.length===0?z(o,n.from,n.to,l):R(n.children,l,n.from,n.to,i,a,o)}s=n.to}s<r&&z(o,s,r,t)}function hn(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===I.LinkMark?(s++,s===2&&(a=t.from)):t.type===I.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c?r.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=r.mdPack.create({key:`link_${c}`}),f=[...t,d],p=e.from;for(let t of e.children){if(t.from>p){let e=u(p)?[...f,l]:f;z(i,p,t.from,e)}let e=u(t.from)?[...f,l]:f;if(t.type===I.Wikilink){_n(t,e,n,r,i),p=t.to;continue}let a=L.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?z(i,t.from,t.to,o):R(t.children,o,t.from,t.to,n,r,i),p=t.to}p<e.to&&z(i,p,e.to,f)}function gn(e,t,n,r,i){let a=e.children.find(e=>e.type===I.URL);if(!a){hn(e,t,n,r,i);return}let o=e.children.filter(e=>e.type===I.LinkMark),s=n.slice(a.from,a.to),c=o.length>=2?n.slice(o[0].to,o[1].from):``,l=r.mdImageSource.create({src:s,alt:c}),u=r.mdImageView.create({src:s,alt:c}),d=r.mdPack.create({key:`image_${s}`}),f=e.to-1,p=e=>e>=f?[...t,d,l,u]:[...t,d,l],m=e.from;for(let t of e.children){t.from>m&&z(i,m,t.from,p(m));let e=L.get(t.type),a=e?[...p(t.from),r[e].create()]:p(t.from);t.children.length===0?z(i,t.from,t.to,a):R(t.children,a,t.from,t.to,n,r,i),m=t.to}m<e.to&&z(i,m,e.to,p(m))}function _n(e,t,n,r,i){let{target:a,display:o}=un(n.slice(e.from,e.to)),s=r.mdWikilinkSource.create({target:a}),c=r.mdWikilinkView.create({target:a,display:o}),l=e.to-1,u=e=>e>=l?[...t,s,c]:[...t,s],d=e.from;for(let t of e.children){t.from>d&&z(i,d,t.from,u(d));let e=r.mdMark.create();t.from<l&&t.to>l?(z(i,t.from,l,[...u(t.from),e]),z(i,l,t.to,[...u(l),e])):z(i,t.from,t.to,[...u(t.from),e]),d=t.to}d<e.to&&z(i,d,e.to,u(d))}function z(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&ln(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const vn=`inline-marks-applied`,yn=new WeakMap;let bn=0,xn=0;function Sn(e,t,n){let r=yn.get(e);if(r?xn++:(bn++,r=pn(Ar(n),e.textContent),yn.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function Cn(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function wn(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=Sn(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function Tn(){return new v({key:new y(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(vn))return null;let r=wn(n,Cn(e,n));if(r.length===0)return null;let i=n.tr.step(new M(r));return i.setMeta(vn,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(En(e.state)),{}}})}function En(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Dn(){return p(Tn())}function On(){return l({name:`mdImageView`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-anchor`},0],parseDOM:[{tag:`span.md-image-anchor`}]})}function kn(){return l({name:`mdImageSource`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-source`},0],parseDOM:[{tag:`span.md-image-source`}]})}function An(){return l({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function jn(){return l({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Mn(){return l({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Nn(){return l({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Pn(){return l({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Fn(){return l({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function In(){return l({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Ln(){return l({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Rn(){return l({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function zn(){return l({name:`mdWikilinkSource`,inclusive:!1,attrs:{target:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-source`},0],parseDOM:[{tag:`span.md-wikilink-source`}]})}function Bn(){return l({name:`mdWikilinkView`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-anchor`},0],parseDOM:[{tag:`span.md-wikilink-anchor`}]})}function Vn(){return l({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{default:``}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Hn(){return h(An(),jn(),Mn(),Nn(),Pn(),Fn(),In(),Ln(),Rn(),zn(),Bn(),kn(),On(),Vn())}function Un(e,t=0){let n=t,r=0;for(let t=0;t<e.length;t++)e.charCodeAt(t)===96?(r++,r>n&&(n=r)):r=0;return n}const B={em:{node:I.Emphasis,delim:`*`},strong:{node:I.StrongEmphasis,delim:`**`},code:{node:I.InlineCode,delim:"`"},del:{node:I.Strikethrough,delim:`~~`},highlight:{node:I.Highlight,delim:`==`}},Wn=new Set([I.EmphasisMark,I.CodeMark,I.LinkMark,I.StrikethroughMark,I.HighlightMark]);function V(e){return[e.children[0],e.children.at(-1)]}function Gn(e){let{type:t,children:n}=e;if(t===I.Emphasis||t===I.StrongEmphasis||t===I.Strikethrough||t===I.Highlight)return[n[0].to,n.at(-1).from];if(t===I.Link||t===I.Image){let e=n.find((e,t)=>t>0&&e.type===I.LinkMark);return e?[n[0].to,e.from]:null}return null}function H(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Gn(r);return i&&i[0]<=t&&n<=i[1]?H(r.children,t,n):H(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Kn(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Kn(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}const U=e=>e===` `||e===` `;function qn(e,t,n){for(;t<n&&U(e[t]);)t++;for(;n>t&&U(e[n-1]);)n--;return[t,n]}function Jn(e,t,n,r){let i=F(P(e),e=>e.type===r.node||Wn.has(e.type));for(let r=t;r<n;r++)if(!U(e[r])&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Yn(e,t,n,r,i){let a=P(e),o=F(a,e=>e.type===r.node);return i?Qn(e,o,t,n):Xn(e,a,o,t,n,r)}function Xn(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=H(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=V(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Zn(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Zn(e,t,n,r,i){if(i.node!==I.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(Un(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Qn(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=V(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Kn(a.children.slice(1,-1),s,c);s>t.to&&U(e[s-1]);)s--;for(;c<o.from&&U(e[c]);)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function $n(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=P(e),o=F(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=V(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return er(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function er(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Gn(n);return!e||t<e[0]||t>e[1]?!0:er(n.children,t)}return!1}function W(e){return(t,n)=>{if(t.selection.empty)return tr(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=qn(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Jn(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Yn(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(b.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function tr(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=$n(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(b.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(b.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function nr(){return o({toggleEm:()=>W(B.em),toggleStrong:()=>W(B.strong),toggleCode:()=>W(B.code),toggleDel:()=>W(B.del),toggleHighlight:()=>W(B.highlight)})}function rr(){return c({"Mod-b":W(B.strong),"Mod-i":W(B.em),"Mod-e":W(B.code),"Mod-Shift-x":W(B.del),"Mod-Shift-h":W(B.highlight)})}function ir(){return h(nr(),rr())}function ar(){return d({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function or(){return d({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function sr(e){return e===2||e===3||e===4}function cr(){return d({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>sr(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return sr(t)?t:1}})}const lr=[C(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),C(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),C(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),C(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function ur(){return h(lr.map(Ie))}function dr(){return S({kind:`task`,marker:`+`})}function fr(){return S({kind:`task`,marker:null})}function pr(){return o({wrapInCircleTask:dr,wrapInSquareTask:fr})}function mr(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function hr(){return(e,t,n)=>{let r=mr(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},S(a)(e,t,n)}}function gr(){return(e,t,n)=>{let r=mr(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},S(a)(e,t,n)}}function _r(){return c({"Mod-Enter":hr(),"Mod-Shift-Enter":gr()})}function vr(){return h(He(),Be(),ze(),Le(),Ve(),Re(),ur(),_r(),ar(),or(),cr(),pr())}function yr(){return f({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function br(){return h(g(yr(),t.highest),Ue(),We())}const xr=(e,t)=>{let{selection:n}=e;return!$e(n)||!n.isColSelection()||!n.isRowSelection()?!1:Qe(e,t)};function Sr(){return g(c({Backspace:xr,Delete:xr}),t.high)}function Cr(){return h(Ze(),Xe(),Ge(),Ye(),Je({allowTableNodeSelection:!0}),Ke(),qe(),Sr())}function wr(){return h(br(),pe(),kt(),ge(),ue(),vr(),Pt(),Cr(),de(),It(),Lt(),Hn(),Et(),Dn(),ir(),fn(),xt({marks:[{name:`mdImageSource`,modes:[`hide`]},{name:`mdWikilinkSource`,modes:[`hide`,`focus`,`show`]}],selectedClass:`md-atomic-selected`}),a(),i(),s(),me(),_e(),he())}function Tr(){return wr()}const Er=_(()=>{let e=Tr().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),Dr=_(()=>r(Er())),Or=_(()=>n(Er())),kr=`meowdown_mark_builders`;function Ar(e){let t=e.cached[kr];if(t)return t;let r=n(e);return e.cached[kr]=r,r}const jr=`meowdown_node_builders`;function Mr(e){let t=e.cached[jr];if(t)return t;let n=r(e);return e.cached[jr]=n,n}function G(e,t={}){let{nodes:n=Dr(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=Pr(e);i=t,n&&(a=e.slice(n))}let o=Fr(n,sn.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const Nr=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function Pr(e){let t=Nr.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function Fr(e,t,n){let r=[];if(!t.firstChild())return r;do r.push(...K(e,t,n));while(t.nextSibling());return t.parent(),r}function K(e,t,n){switch(t.type.id){case I.ATXHeading1:return[q(e,t,n,1,!1)];case I.ATXHeading2:return[q(e,t,n,2,!1)];case I.ATXHeading3:return[q(e,t,n,3,!1)];case I.ATXHeading4:return[q(e,t,n,4,!1)];case I.ATXHeading5:return[q(e,t,n,5,!1)];case I.ATXHeading6:return[q(e,t,n,6,!1)];case I.SetextHeading1:return[q(e,t,n,1,!0)];case I.SetextHeading2:return[q(e,t,n,2,!0)];case I.Paragraph:return[Z(e,t,n)];case I.CommentBlock:return[Rr(e,t,n)];case I.HTMLBlock:case I.ProcessingInstructionBlock:return[Z(e,t,n)];case I.Blockquote:return[zr(e,t,n)];case I.BulletList:return Br(e,t,n,`bullet`);case I.OrderedList:return Br(e,t,n,`ordered`);case I.FencedCode:case I.CodeBlock:return[Hr(e,t,n)];case I.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case I.Table:return[Ur(e,t,n)];case I.Task:return[Z(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Z(e,t,n)])}}function q(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===I.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===I.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Y(n.slice(o,s),J(n,o)).trim(),d=i?Ir(n,c,l)||1:null;return e.heading({level:r,setextUnderline:d},u)}function Ir(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function J(e,t){let n=e.lastIndexOf(`
|
|
3
|
+
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function Lr(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function Y(e,t){return t===0||!e.includes(`
|
|
5
4
|
`)?e:e.split(`
|
|
6
|
-
`).map((e,n)=>n===0?e:
|
|
7
|
-
`)}function X(e,t,n){return e.paragraph(
|
|
5
|
+
`).map((e,n)=>n===0?e:Lr(e,t)).join(`
|
|
6
|
+
`)}function X(e,t,n){return e.paragraph(Y(t,n))}function Z(e,t,n){let r=t.from,i=t.to,a=J(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===I.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,Gt(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),X(e,o,a)}return X(e,n.slice(r,i),a)}function Rr(e,t,n){let r=J(n,t.from),i=Y(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function zr(e,t,n){let r=[];if(t.firstChild()){do{if(t.type.id===I.QuoteMark)continue;r.push(...K(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function Br(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===I.ListItem&&i.push(Vr(e,t,n,r));while(t.nextSibling());t.parent()}return i}function Vr(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==I.ListMark&&u==null&&(u=J(n,t.from)),t.type.id===I.ListMark){if(r===`ordered`){let e=n.charCodeAt(t.to-1);e===41?c=`)`:e===46&&(c=`.`);let r=Number.parseInt(n.slice(t.from,t.to),10);s=Number.isFinite(r)?r:1}else{let e=n.charCodeAt(t.from);c=e===42?`*`:e===43?`+`:`-`}l=J(n,t.to);continue}if(r===`bullet`&&t.type.id===I.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===I.TaskMarker){let e=n.charCodeAt(t.from+1);e===120?(a=!0,o=`x`):e===88&&(a=!0,o=`X`),r=t.to}t.parent()}Gt(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(X(e,c,J(n,r)));continue}i.push(...K(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1;return e.list({kind:a==null?r:`task`,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:!1,marker:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1},i)}function Hr(e,t,n){let r=``,i=``;if(t.firstChild()){do switch(t.type.id){case I.CodeInfo:r=n.slice(t.from,t.to);break;case I.CodeText:i+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:r},i)}function Ur(e,t,n){let r=0;if(t.firstChild()){do t.type.id===I.TableDelimiter&&(r=Wr(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===I.TableHeader?i.push(Gr(e,t,n,!0,r)):a===I.TableRow&&i.push(Gr(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Wr(e){return e.split(`|`).filter(e=>e.trim()!==``).length}function Gr(e,t,n,r,i){let a=Array(i).fill(``);if(t.firstChild()){let e=t.type.id===I.TableDelimiter,r=0;do if(t.type.id===I.TableDelimiter)r++;else if(t.type.id===I.TableCell){let o=r-+!!e;o>=0&&o<i&&(a[o]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let o=a.map(t=>{let n=e.paragraph(t);return r?e.tableHeaderCell(n):e.tableCell(n)});return e.tableRow(o)}function Q(e,t={}){let n=new Yr;return t.frontmatter&&Kr(e.attrs.frontmatter,n),Xr(e,n),n.finish()}function Kr(e,t){e!==null&&(t.write(`---`),t.write(`
|
|
8
7
|
`),e!==``&&(t.write(e),t.write(`
|
|
9
|
-
`)),t.write(`---`),t.closeBlock())}const
|
|
10
|
-
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(
|
|
8
|
+
`)),t.write(`---`),t.closeBlock())}const qr=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function Jr(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){$r(e,t);let i=n.level===1?`=`:`-`;t.write(`
|
|
9
|
+
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(qr[n.level]??`# `),$r(e,t),t.closeBlock()}var Yr=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
|
|
11
10
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
12
11
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
13
12
|
`,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeBlock(){this.atLineStart&&this.pendingFirst!==null&&(this.emitDeferredBlankLine(),this.parts.push(this.pendingFirst.trimEnd()),this.pendingFirst=null,this.atLineStart=!1),this.atLineStart||this.parts.push(`
|
|
14
13
|
`),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=t===null?i:null}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
|
|
15
14
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
16
|
-
`),this.deferredBlankPrefix=null)}};function
|
|
15
|
+
`),this.deferredBlankPrefix=null)}};function Xr(e,t){switch(e.type.name){case`doc`:$(e,t);return;case`paragraph`:$r(e,t),t.closeBlock();return;case`heading`:Jr(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>$(e,t)),t.closeBlock();return;case`list`:ei(e,t,Qr(e));return;case`codeBlock`:ti(e,t);return;case`horizontalRule`:{let{marker:n}=e.attrs;t.write(n||`---`),t.closeBlock();return}case`htmlComment`:{let{content:n}=e.attrs;t.write(n),t.closeBlock();return}case`table`:ni(e,t);return;case`text`:e.text&&t.write(e.text);return}}function $(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(a.type.name!==`list`){n&&i>0&&t.suppressBlank(),Xr(a,t),i++;continue}let o=i+1;for(;o<r&&e.child(o).type.name===`list`;)o++;let s=Zr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),ei(e.child(r),t,s);i=o}}function Zr(e,t,n){for(let r=t;r<n;r++)if(!Qr(e.child(r)))return!1;return!0}function Qr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n);if(t.type.name!==`list`&&!(t.type.name===`paragraph`&&n===0))return!1}return!0}function $r(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function ei(e,t,n){let r=e.attrs,i=r.marker===`*`||r.marker===`+`?r.marker:`-`,a=r.marker===`)`?`)`:`.`,o=r.taskMarker===`X`?`X`:`x`,s=Math.min(Math.max(r.markerGap??1,1),4),c=`${r.kind===`ordered`?`${r.order??1}${a}`:i}${` `.repeat(s)}`,l=r.kind===`task`?`${c}[${r.checked?o:` `}] `:c,u=` `.repeat(c.length);t.withPrefix(u,l,()=>$(e,t,n)),t.closeBlock()}function ti(e,t){let n=e.attrs.language||``,r=e.textContent,i="`".repeat(Un(r,2)+1);t.write(i),n&&t.write(n),t.write(`
|
|
17
16
|
`),r&&(t.write(r),t.write(`
|
|
18
|
-
`)),t.write(i),t.closeBlock()}function
|
|
17
|
+
`)),t.write(i),t.closeBlock()}function ni(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);t.type.name===`tableHeaderCell`&&(s=!0),o.push(ii(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=`| `+Array(i).fill(`---`).join(` | `)+` |`,s=a>=0?r[a]:Array(i).fill(``);t.write(ri(s,i)),t.write(`
|
|
19
18
|
`),t.write(o);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
20
|
-
`),t.write(
|
|
19
|
+
`),t.write(ri(r[e],i)));t.closeBlock()}function ri(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function ii(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
21
20
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
22
|
-
`,` `)}
|
|
21
|
+
`,` `)}function ai(e){return e.replace(/\n+$/u,``)}function oi(e){return/^[\s>]*$/u.test(e)}function si(e){return e.split(`
|
|
22
|
+
`).filter(e=>!oi(e))}function ci(e,t={}){let n=Q(G(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(ai(n)===ai(e))return`exact`;let r=si(e),i=si(n);return r.length===i.length&&r.every((e,t)=>e.trimEnd()===i[t].trimEnd())?`normalizing`:`lossy`}const li=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||n.parent.type.name!==`heading`||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=te(e.schema,`list`),i=te(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(b.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function ui(){return g(c({Enter:li}),t.high)}const di=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`]),fi=be.map(e=>e.name).filter(e=>!di.has(e)).map(e=>({label:e,value:e.toLowerCase()})).concat({label:`Plain text`,value:``}).sort((e,t)=>e.label.localeCompare(t.label));function pi(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const mi=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,hi=/\/status(?:es)?\/(\d+)/;function gi(e){let t;try{t=new URL(e)}catch{return}if(mi.test(t.hostname))return hi.exec(t.pathname)?.[1]}const _i=e=>{let t=gi(e);if(!t)return;let n=pi()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function vi(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const yi=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,bi=/^(?:www\.)?youtu\.be$/i,xi=/^[\w-]{11}$/;function Si(e){let t;try{t=new URL(e)}catch{return}let n=null;if(bi.test(t.hostname))n=t.pathname.slice(1);else if(yi.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!xi.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Ci(r):void 0;return{videoId:n,startSeconds:i}}function Ci(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const wi=[e=>{let t=Si(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},_i];function Ti(e){for(let t of wi){let n=t(e);if(n)return n}}const Ei=new y(`meowdown-embed-paste`);function Di(e){let t=e.trim();if(!(!t||/\s/.test(t)))return Ti(t)?t:void 0}function Oi(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
23
|
+
`)}function ki(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(et(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(et(i))}function Ai(){return p(new v({key:Ei,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=Oi(t,n);if(!i)return!1;let a=Di(i);return a?(ki(e,a),!0):!1}}}))}const ji=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Mi=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function Ni(){return at().use(tt).use(nt,{handlers:{mark:ji}}).use(rt).use(it,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Mi}}).freeze()}const Pi=_(Ni);function Fi(e){return String(Pi().processSync(e))}const Ii=new y(`meowdown-html-paste`);function Li(){return p(new v({key:Ii,props:{transformPastedHTML:(e,t)=>{if(e.includes(`data-pm-slice`))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=Fi(e);if(!r.trim())return e;let i=G(r,{nodes:Mr(t.state.schema)}),a=Me.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const Ri=new y(`meowdown-image-click`);function zi(e,t){let n=w(e,t,`mdImageSource`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Bi(e){return p(new v({key:Ri,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=zi(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function Vi(e){return/^https?:\/\//i.test(e)?e:void 0}function Hi(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&vi(t),t}function Ui(e,t,n){let r=Ti(e);if(r){let e=document.createElement(`span`);return e.className=`md-image-preview md-image-preview-embed`,e.appendChild(Hi(r)),e}let i=(n.resolveImageUrl??Vi)(e);if(!i)return;let a=document.createElement(`span`);a.className=`md-image-preview md-image-preview-img`,a.dataset.testid=`image-preview`;let o=document.createElement(`img`);return o.src=i,o.alt=t,o.draggable=!1,a.appendChild(o),a}function Wi(e){return t=>{let n=t.attrs,r=document.createElement(`span`);r.className=`md-image-view`;let i=document.createElement(`span`);i.className=`md-image-view-content`,r.appendChild(i);let a=Ui(n.src,n.alt,e);return a&&(a.contentEditable=`false`,r.appendChild(a)),{dom:r,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function Gi(e){return e?Array.from(e.files).filter(e=>e.type.startsWith(`image/`)):[]}const Ki=e=>{console.error(`[meowdown] failed to save pasted image:`,e)};async function qi(e,t,n,r=Ki,i){let a=i;for(let i of t){let t;try{t=await n(i)}catch(e){r(e,i);continue}if(!t||e.isDestroyed)continue;let o=``,s=a==null?e.state.tr.insertText(o):e.state.tr.insertText(o,a);e.dispatch(s),a!=null&&(a+=o.length)}}function Ji(e){return new v({key:new y(`image-input`),props:{handlePaste:(t,n)=>{let r=Gi(n.clipboardData),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(qi(t,r,i,a),!0)},handleDrop:(t,n)=>{let r=Gi(n.dataTransfer),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(qi(t,r,i,a,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function Yi(e={}){return h(u({name:`mdImageView`,constructor:Wi(e)}),g(p(Ji(e)),t.high))}const Xi={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`};function Zi(e){return p(new v({key:e.key,props:{handleClick:(t,n,r)=>{if(!r.target?.closest?.(e.selector))return!1;let i=e.findPayloadAt(t.state,n);return i==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(i,r),!0)}}}))}const Qi=new y(`meowdown-link-click`);function $i(e,t){let n=w(e,t,`mdLinkText`);if(n)return{from:n.from,to:n.to,href:n.mark.attrs.href}}function ea(e){return Zi({key:Qi,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>$i(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}const ta=new y(`meowdown-markdown-copy`);function na(){return p(new v({key:ta,props:{clipboardTextSerializer:(e,t)=>{let n=e.content,r;try{r=t.state.schema.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?Q(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
23
24
|
`,`
|
|
24
|
-
`)}}}))}const
|
|
25
|
-
`).filter(e=>!Qi(e))}function ea(e,t={}){let n=ki(K(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(Zi(n)===Zi(e))return`exact`;let r=$i(e),i=$i(n);return r.length===i.length&&r.every((e,t)=>e.trimEnd()===i[t].trimEnd())?`normalizing`:`lossy`}export{Ji as EDITOR_KEY_BINDINGS,e as Priority,ea as checkRoundTrip,Xi as codeBlockLanguages,Jr as defaultResolveImageUrl,Gi as defineBulletAfterHeading,Dt as defineCodeBlockSyntaxHighlight,Or as defineEditorExtension,ui as defineEmbedPaste,Oi as defineHTMLPaste,ni as defineImage,ai as defineImageClickHandler,Fr as defineLinkClickHandler,ft as defineMarkMode,Ui as defineMarkdownCopy,ot as definePlaceholder,st as defineReadonly,Mr as defineWikilinkClickHandler,qi as defineWikilinkTrigger,ki as docToMarkdown,kt as getCodeTokens,_n as getMarkBuilders,un as inlineTextToMarkChunks,Vr as listenForTweetHeight,K as markdownToDoc,G as matchEmbed,se as withPriority};
|
|
25
|
+
`)}}}))}const ra=new y(`meowdown-tag-click`);function ia(e,t){let n=w(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function aa(e){return Zi({key:ra,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>ia(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const oa=new y(`meowdown-wikilink-click`);function sa(e,t){let n=w(e,t,`mdWikilinkSource`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function ca(e){return Zi({key:oa,selector:`.md-wikilink-label, .md-wikilink-source`,preventDefault:!1,findPayloadAt:(e,t)=>sa(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const la=(e,t)=>{let{selection:n}=e;if(!n.empty&&!n.$head.sameParent(n.$anchor))return!1;let r=e.doc.textBetween(n.from,n.to);if(r.startsWith(`[[`))return!1;r.startsWith(`[`)&&(r=r.slice(1));let i=`[[`+r;if(t){let r=e.tr.insertText(i,n.from,n.to);r.setSelection(b.create(r.doc,n.from+i.length)),ot(r),t(r.scrollIntoView())}return!0};function ua(){return c({"Mod-Shift-k":la})}export{Xi as EDITOR_KEY_BINDINGS,e as Priority,ci as checkRoundTrip,fi as codeBlockLanguages,Vi as defaultResolveImageUrl,ui as defineBulletAfterHeading,Et as defineCodeBlockSyntaxHighlight,Tr as defineEditorExtension,Ai as defineEmbedPaste,Lt as defineHTMLComment,Li as defineHTMLPaste,Yi as defineImage,Bi as defineImageClickHandler,ea as defineLinkClickHandler,dt as defineMarkMode,na as defineMarkdownCopy,ce as definePlaceholder,le as defineReadonly,aa as defineTagClickHandler,ca as defineWikilinkClickHandler,ua as defineWikilinkTrigger,Q as docToMarkdown,Ot as getCodeTokens,Or as getMarkBuilders,pn as inlineTextToMarkChunks,vi as listenForTweetHeight,G as markdownToDoc,Ti as matchEmbed,oe as withPriority};
|
package/dist/style.css
CHANGED
|
@@ -153,6 +153,7 @@ img.ProseMirror-separator {
|
|
|
153
153
|
--meowdown-muted: light-dark(#52525b, #a1a1aa);
|
|
154
154
|
--meowdown-accent: light-dark(#7c3aed, #c084fc);
|
|
155
155
|
--meowdown-mark: light-dark(#a78bfa, #8b5cf6);
|
|
156
|
+
--meowdown-highlight: light-dark(#fef08a, #854d0e);
|
|
156
157
|
--meowdown-border: light-dark(#e4e4e7, #3f3f46);
|
|
157
158
|
--meowdown-code-bg: light-dark(#f4f4f5, #18181b);
|
|
158
159
|
--meowdown-table-header-bg: light-dark(#fafafa, #27272a);
|
|
@@ -226,6 +227,15 @@ img.ProseMirror-separator {
|
|
|
226
227
|
text-decoration: underline 1px;
|
|
227
228
|
}
|
|
228
229
|
|
|
230
|
+
.ProseMirror mark {
|
|
231
|
+
background: var(--meowdown-highlight);
|
|
232
|
+
color: inherit;
|
|
233
|
+
-webkit-box-decoration-break: clone;
|
|
234
|
+
box-decoration-break: clone;
|
|
235
|
+
border-radius: 2px;
|
|
236
|
+
padding: 0 1px;
|
|
237
|
+
}
|
|
238
|
+
|
|
229
239
|
.ProseMirror code {
|
|
230
240
|
font-family: var(--meowdown-font-mono);
|
|
231
241
|
background: color-mix(in oklab, var(--meowdown-accent) 10%, transparent);
|
|
@@ -432,6 +442,7 @@ img.ProseMirror-separator {
|
|
|
432
442
|
.ProseMirror .md-tag {
|
|
433
443
|
background: color-mix(in oklab, var(--meowdown-accent) 10%, transparent);
|
|
434
444
|
color: color-mix(in oklab, var(--meowdown-accent) 80%, var(--meowdown-heading));
|
|
445
|
+
cursor: pointer;
|
|
435
446
|
border-radius: .35rem;
|
|
436
447
|
padding: .1em .35em;
|
|
437
448
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.23.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -38,9 +38,12 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@ocavue/tsconfig": "^0.7.1",
|
|
40
40
|
"@tsdown/css": "^0.22.3",
|
|
41
|
+
"@types/mdast": "^4.0.4",
|
|
41
42
|
"@vitest/browser-playwright": "^4.1.9",
|
|
42
43
|
"dedent": "^1.7.2",
|
|
43
44
|
"diffable-html-snapshot": "^0.3.0",
|
|
45
|
+
"hast-util-to-mdast": "^10.1.2",
|
|
46
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
44
47
|
"tsdown": "^0.22.3",
|
|
45
48
|
"vitest": "^4.1.9",
|
|
46
49
|
"@meowdown/vitest": "0.0.0"
|